package com.ruoyi.xh.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TablePageDataInfo;
import com.ruoyi.common.core.domain.CommentResult;
import com.ruoyi.xh.domain.XhPurchaseOrderDesc;
import com.ruoyi.xh.service.IXhPurchaseOrderDescService;

/**
 * 集采详情Controller
 *
 * @author songjw
 * @date 2024-12-13
 */
@Api(tags = "集采详情Controller",value = "集采详情Controller")
@RestController
@RequestMapping("/xh/purchaseOrderDesc")
public class XhPurchaseOrderDescController extends BaseController {

    @Autowired
    private IXhPurchaseOrderDescService xhPurchaseOrderDescService;

    /**
     * 查询集采详情列表
     */
    @PreAuthorize("@ss.hasPermi('xh:purchaseOrderDesc:list')")
    @GetMapping("/list")
    @ApiOperation("查询集采详情列表")
    public TablePageDataInfo<XhPurchaseOrderDesc> list(XhPurchaseOrderDesc xhPurchaseOrderDesc) {
        return TablePageDataInfo.success(xhPurchaseOrderDescService.selectXhPurchaseOrderDescList(xhPurchaseOrderDesc));
    }

    /**
     * 获取集采详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('xh:purchaseOrderDesc:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取集采详情详细信息")
    public CommentResult<XhPurchaseOrderDesc> getInfo(@PathVariable("id") Long id) {
        return CommentResult.success(xhPurchaseOrderDescService.selectXhPurchaseOrderDescById(id));
    }

    /**
     * 新增集采详情
     */
    @PreAuthorize("@ss.hasPermi('xh:purchaseOrderDesc:add')")
    @Log(title = "集采详情", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增集采详情")
    public CommentResult<XhPurchaseOrderDesc> add(@RequestBody XhPurchaseOrderDesc xhPurchaseOrderDesc) {
            xhPurchaseOrderDescService.insertXhPurchaseOrderDesc(xhPurchaseOrderDesc);
        return CommentResult.success();
    }

    /**
     * 修改集采详情
     */
    @PreAuthorize("@ss.hasPermi('xh:purchaseOrderDesc:edit')")
    @Log(title = "集采详情", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改集采详情")
    public CommentResult<XhPurchaseOrderDesc> edit(@RequestBody XhPurchaseOrderDesc xhPurchaseOrderDesc) {
            xhPurchaseOrderDescService.updateXhPurchaseOrderDesc(xhPurchaseOrderDesc);
        return CommentResult.success();
    }

    /**
     * 删除集采详情
     */
    @PreAuthorize("@ss.hasPermi('xh:purchaseOrderDesc:remove')")
    @Log(title = "集采详情", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation("删除集采详情")
    public CommentResult<XhPurchaseOrderDesc> remove(@PathVariable Long[] ids) {
            xhPurchaseOrderDescService.deleteXhPurchaseOrderDescByIds(ids);
        return CommentResult.success();
    }
}
